﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindFrmTx
{
    class DbHelp
    {
        private static readonly string conString = "server=.;database = Blogs;uid =sa;pwd=zx135246;";
        public static DataTable dataTable(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);

        

            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, sqlConnection);

            DataTable dt = new DataTable();
            sqlConnection.Open();

            dataAdapter.Fill(dt);
            return dt;
        }
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            return command.ExecuteNonQuery();

        }
    }
}
